package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"github.com/spf13/viper"
	"m/Global"
	"m/GoFile"
	"m/router"
	"os"
)



func main() {
	InitConfig()

	var erre error
	Global.CDb, erre = GoFile.InitRedisDB()
	if erre != nil {
		fmt.Println("initredisdb执行失败", erre.Error())
		return
	}

	var err error
	Global.Db, err = GoFile.InitDB()
	re := gin.Default()
	//re = AllRouter(re)
	if err != nil {
		fmt.Println("数据库连接失败！")
		return
	}
	re = router.CreateRoute(re)
	panic(re.Run(":8081"))
}

func InitConfig() {
	workDir, _:=os.Getwd()
	viper.SetConfigName("application")
	viper.SetConfigType("yml")
	viper.AddConfigPath(workDir + "/config")
	err := viper.ReadInConfig()
	if err != nil {

	}
}
